package com.hadoop.fs;

import java.io.InputStream;
import java.net.URL;

import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
import org.apache.hadoop.io.IOUtils;

public class UrlCat {

	static {
		//需要让URL类能够支持hdfs://协议，还需要设置hdfs的协议处理类。
		URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
	}

	public static void main(String[] args) throws Exception {
		InputStream in = null;
		try{
			in = new URL(args[0]).openStream();
			IOUtils.copyBytes(in,System.out, 4096,false);
		}finally{
			IOUtils.closeStream(in);
		}
	}

}
